#include "PxLog.h"
#include "log4cplus\logger.h"
#include "log4cplus\consoleappender.h"
#include "log4cplus\loggingmacros.h"

using namespace log4cplus;

CPxLog::CPxLog()
	:m_pConsoleAppender(new ConsoleAppender())
{
}


CPxLog::~CPxLog()
{
}

int CPxLog::Init()
{
	m_LogImpl = Logger::getInstance("PxLog");
	m_LogImpl.addAppender(m_pConsoleAppender);

	return 0;
}

void CPxLog::LogMsg(char* szMsg, int nLogLevel /* = INFO_LOG_LEVEL */)
{
	switch (nLogLevel)
	{
	case WARN_LOG_LEVEL:
	{
		LOG4CPLUS_WARN(m_LogImpl, szMsg);
		break;
	}
	case ERROR_LOG_LEVEL:
	{
		LOG4CPLUS_ERROR(m_LogImpl, szMsg);
		break;
	}
	case FATAL_LOG_LEVEL:
	{
		LOG4CPLUS_FATAL(m_LogImpl, szMsg);
		break;
	}
	case DEBUG_LOG_LEVEL:
	{
		LOG4CPLUS_DEBUG(m_LogImpl, szMsg);
		break;
	}
	case TRACE_LOG_LEVEL:
	{
		LOG4CPLUS_TRACE(m_LogImpl, szMsg);
		break;
	}
	default:
	{
		LOG4CPLUS_INFO(m_LogImpl, szMsg);
		break;
	}
	}
}